package com.zxhysy.log.test.controller;

import com.zxhysy.log.annotation.Log;
import com.zxhysy.log.annotation.LogConfig;
import com.zxhysy.log.annotation.context.LogContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangxinhong
 * @since 2021/9/6 9:31
 */
@LogConfig(bizType = "部门管理", logType = "操作日志")
@RestController
@RequestMapping("/web")
public class WebController {

    @Log(success = "'成功:' + #id + #hello(#id)", description = "hello方法", fail = "'失败：' + #id")
    @GetMapping("/hello")
    public String hello(String id) {
        return "hello" + id;
    }

    @Log(success = "@testService.test(#id)", description = "hello2方法", fail = "'失败：' + #id")
    @GetMapping("/hello2")
    public String hello2(String id) {
        return "hello2" + id;
    }

    @Log(success = "@testService.test(#name)", description = "hello3方法", fail = "'失败：' + #id")
    @GetMapping("/hello3")
    public String hello3(String id) {
        LogContext.putVariable("name", "testPutVariable");
        return "hello3" + id;
    }
}
